
/**
** \file       execution.h
**
** \brief      Here are declared functions which deal with the execution
**
** \authors    Ben M'rad Hanna, Boillot Ulysse, De Oliveira Guillaume,
**             Laterem Hamza and Nguyen Viet Dung.
**
** \version    0.8
**
** \date       26 November 2010
**
*/

#ifndef EXECUTION_H_
# define EXECUTION_H_

# include <stdlib.h>
# include <string.h>
# include <unistd.h>
# include <sys/types.h>
# include <sys/wait.h>

# include "../parser/ast.h"
# include "../exec_cmdline.h"

/*!
** \def NB_REDIR
*/
# define NB_REDIR       7

/**
** \fn         int     exec_command(s_command      *node)
**
**
** \brief      this function execute a command
**
** \param      s_command    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_command(s_command          *node);

/**
** \fn         int     exec_input(s_ast      *node)
**
**
** \brief      this function start the execution of the ast
**
** \param      s_ast   *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_input(s_ast                *node);

/**
** \fn         int     exec_andor(struct andor      *node)
**
**
** \brief      this function execute the andor rule
**
** \param      struct andor   *node
**
** \return     return 0 on succeed, 1 else
**
*/

int	exec_andor(struct andor         *node);

/**
** \fn         int     exec_pipeline(s_pipeline      *node)
**
**
** \brief      this function handle the execution of the pipeline rule
**
** \param      s_pipeline    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int	exec_pipeline(s_pipeline	*node);

/**
** \fn         int     exec_funcdec(s_funcdec      *node)
**
**
** \brief
**
** \param      s_funcdec    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_funcdec(s_funcdec          *node);

/**
** \fn         int     exec_shcmd(s_sh_cmd      *node)
**
**
** \brief      this function execute a shell command
**
** \param      s_sh_cmd    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_shcmd(s_sh_cmd             *node);

/**
** \fn         int     exec_smpcmd(s_smp_cmd      *node)
**
**
** \brief      this function execute a simple command
**
** \param      s_smp_cmd    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_smpcmd(s_smp_cmd           *node);

/**
** \fn         int     exec_elt(s_element      *node)
**
**
** \brief      this function execute the rule element
**
** \param      s_element    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_elt(s_element              *node);

/**
** \fn         int     exec_cmpdlist(s_cmpdlist      *node)
**
**
** \brief      this function execute the compoundlist rule
**
** \param      s_cmpdlist    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_cmpdlist(s_cmpdlist        *node);

/**
** \fn         int     exec_for(s_rulefor      *node)
**
**
** \brief      this function handle the execution of for
**
** \param      s_rulefor    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_for(s_rulefor              *node);

/**
** \fn         int     exec_if(s_ruleif      *node)
**
**
** \brief      this funcion execute the alternative if
**
** \param      s_ruleif    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_if(s_ruleif                *node);

/**
** \fn         int     exec_case(s_rulecase      *node)
**
**
** \brief      this function execute the case rule
**
** \param      s_rulecase    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_case(s_rulecase            *node);

/**
** \fn         int     exec_list(s_list      *node)
**
**
** \brief      this function execute the list rule
**
** \param      s_list    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_list(s_list                *node);

/**
** \fn         int     exec_prefix(s_prefix      *node)
**
**
** \brief      this function execute the prefix rule
**
** \param      s_prefix    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_prefix(s_prefix            *node);

/**
** \fn         int     exec_else_clause(s_else_clause      *node)
**
**
** \brief      this function execute else_clause rule
**
** \param      s_else_clause    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_else_clause(s_else_clause  *node);

/**
** \fn         int     exec_dogroup(s_dogroup      *node)
**
**
** \brief      this function execute the dogroup rule
**
** \param      s_dogroup    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_dogroup(s_dogroup  *node);

/**
** \fn         int     exec_redir(s_redir      *node)
**
**
** \brief      this function execute the redirection rule
**
** \param      s_redir    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_redir(s_redir              *node);

/**
** \fn         int     exec_until(s_ruleuntil      *node)
**
**
** \brief      this function execute the until rule
**
** \param      s_ruleuntil    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_until(s_ruleuntil  *node);

/**
** \fn         int     exec_while(s_rulewhile      *node)
**
**
** \brief      this function execute the while rule
**
** \param      s_rulewhile    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_while(s_rulewhile  *node);

/**
** \fn         int     exec_caseitem(s_caseitem      *node)
**
**
** \brief      this function execute the rule case_item
**
** \param      s_caseitem    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_caseitem(s_caseitem        *node);

/**
** \fn        int     exec_caseclause(s_caseclause      *node)
**
**
** \brief      this function execute the case_clause rule
**
** \param      s_caseclause    *node
**
** \return     return 0 on succeed, 1 else
**
*/

int     exec_case_clause(s_caseclause   *node);

#endif /* !EXECUTION_H_ */
